package com.chen.controller;

import com.chen.service.UserService;
import com.chen.vo.Result;
import com.chen.vo.param.UserParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:chenao
 * @DATE:2022/3/13 18:05
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 查询会员列表
     * @param param
     * @return
     */
    @PostMapping("list")
    public Result listUser(@RequestBody UserParam param){
        return userService.listUser(param);
    }

    /**
     * 修改账户会员卡类型
     * @param param
     * @return
     */
    @PostMapping("category")
    public Result updateCategory(@RequestBody UserParam param){
        return userService.updateCategory(param);
    }

    /**
     * 充值
     * @param param 会员id和充值数额
     * @return
     */
    @PostMapping("recharge")
    public Result recharge(@RequestBody UserParam param){
        return userService.updateBalance(param);
    }

    /**
     * 重置会员类型为普通会员，并重余额和剩余时间等
     * @param param
     * @return
     */
    @PostMapping("reset")
    public Result resetUser(@RequestBody UserParam param){
        return userService.resetUser(param);
    }

    /**
     * 用于统计交易金额
     * @return
     */
    @PostMapping("trade")
    public Result getTrade(){
        return userService.statisticTrade();
    }
}
